unit uInNomineSuperiors;

interface

uses
  SysUtils,
  uInNomineSystem;

function GetFamousSuperior(famousSuperior: TFamousSuperior): TSuperior;
function IsAngelic(superior: TSuperior): boolean; overload;

implementation

function GetFamousSuperior(famousSuperior: TFamousSuperior): TSuperior;

  procedure SetDistinctions(superior: TSuperior; distinctionsDescriptions: array of const);
  var
    i: integer;
  begin
    for i := 0 to 2 do
    begin
      superior.distinctions[i] := TDistinction.Create;
      superior.distinctions[i].description := distinctionsDescriptions[i].VString^;
      superior.distinctions[i].level := i + 1;
    end;
  end;

  procedure AddServitorAttunement(superior: TSuperior; description: String);
  var
    attunement: TAttunement;
  begin
      attunement := TAttunement.Create;
      attunement.superior := superior;
      attunement.description := description;
      superior.servitorAttunements.Add(attunement);
  end;

var
  i: integer;
  tempAttunement: TAttunement;
begin
  case famousSuperior of
    blandine:
    begin
      Result := TSuperior.Create('Dreams');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := cherubim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(blandine)];

      AddServitorAttunement(Result, 'Dream Walking');
      AddServitorAttunement(Result, 'Healing Dream');

      SetDistinctions(Result, ['Vassal of Dreams', 'Friend of Sleepers', 'Master of the Realms of Night']);
    end;
    david:
    begin
      Result := TSuperior.Create('Stone');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := malakim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(david)];

      AddServitorAttunement(Result, 'Deep Gaze');
      AddServitorAttunement(Result, 'Cold Touch');

      SetDistinctions(Result, ['Vassal of Stone', 'Friend of Subterranean World', 'Master of the Granite Hand']);
    end;
    dominic:
    begin
      Result := TSuperior.Create('Judgement');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := seraphim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(dominic)];

      AddServitorAttunement(Result, 'Incarnate Law');
      AddServitorAttunement(Result, 'Heavenly Judgement');

      SetDistinctions(Result, ['Vassal of Conscience', 'Friend of Judgement', 'Master of Law']);
    end;
    eli:
    begin
      Result := TSuperior.Create('Creation');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := mercurians;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(eli)];

      AddServitorAttunement(Result, 'Abracadabra');
      AddServitorAttunement(Result, 'Transubstantiation');
    end;
    gabriel:
    begin
      Result := TSuperior.Create('Fire');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := ofanim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(gabriel)];

      AddServitorAttunement(Result, 'Dance of the Atoms');
      AddServitorAttunement(Result, 'Smite');

      SetDistinctions(Result, ['Vassal of Fire', 'Friend of Divine Spark', 'Master of Light']);
    end;
    janus:
    begin
      Result := TSuperior.Create('Wind');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := ofanim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(janus)];

      AddServitorAttunement(Result, 'Passage');
      AddServitorAttunement(Result, 'Swipe');

      SetDistinctions(Result, ['Vassal of Wind', 'Friend of Unseen', 'Master of Motion']);
    end;
    jean:
    begin
      Result := TSuperior.Create('Lightning');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := elohim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(jean)];

      AddServitorAttunement(Result, 'Generator');
      AddServitorAttunement(Result, 'Remote Control');

      SetDistinctions(Result, ['Vassal of Lightning', 'Friend of the Illuminated', 'Master of the Machine']);
    end;
    jordi:
    begin
      Result := TSuperior.Create('Animals');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := kyriotates;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(jordi)];

      AddServitorAttunement(Result, 'Call of the Wind');
      AddServitorAttunement(Result, 'Animal Magnetism');

      SetDistinctions(Result, ['Vassal of Animals', 'Friend of Beasts', 'Master of the Creature Within']);
    end;
    laurence:
    begin
      Result := TSuperior.Create('Sword');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := malakim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(laurence)];

      AddServitorAttunement(Result, 'Blade Blessing of Laurence');
      AddServitorAttunement(Result, 'Hunt');

      SetDistinctions(Result, ['Vassal of Sword', 'Friend of the Lord''s Troops', 'Master of the Armies of God']);
    end;
    marc:
    begin
      Result := TSuperior.Create('Trade');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := mercurians;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(marc)];

      AddServitorAttunement(Result, 'Divine Contract');
      AddServitorAttunement(Result, 'Head of a PIN');

      SetDistinctions(Result, ['Vassal of Trade', 'Friend of the Shareholders', 'Master of Finances']);
    end;
    michael:
    begin
      Result := TSuperior.Create('War');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := seraphim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(michael)];

      AddServitorAttunement(Result, 'Proficiency');
      AddServitorAttunement(Result, 'Howl');

      SetDistinctions(Result, ['Vassal of War', 'Friend of the Fighters', 'Master of Valor']);
    end;
    novalis:
    begin
      Result := TSuperior.Create('Flowers');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := cherubim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(novalis)];

      AddServitorAttunement(Result, 'Nothing But Flowers');
      AddServitorAttunement(Result, 'Crown of Joy');

      SetDistinctions(Result, ['Vassal of Flowers', 'Friend of the Gardeners', 'Master of Peace']);
    end;
    yves:
    begin
      Result := TSuperior.Create('Destiny');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      SysFreeMem(Result.celestialKind);
      Result.celestialKind := nil;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(yves)];

      AddServitorAttunement(Result, 'Divine Destiny');
      AddServitorAttunement(Result, 'Divine Logic');

      SetDistinctions(Result, ['Vassal of Destiny', 'Friend of the Sages', 'Master of Divine Knowledge']);
    end;
    andrealphus:
    begin
      Result := TSuperior.Create('Lust');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := impudites;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(andrealphus)];

      AddServitorAttunement(Result, 'Dark Desire');
      AddServitorAttunement(Result, 'Kiss of Death');

      SetDistinctions(Result, ['Knight of Infernal Pleasures', 'Captain of Diabolical Delight', 'Baron of Eternal Ecstasy']);
    end;
    asmodeus:
    begin
      Result := TSuperior.Create('Game');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := djinn;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(asmodeus)];

      AddServitorAttunement(Result, 'Dissonance Binding');
      AddServitorAttunement(Result, 'Humanity');

      SetDistinctions(Result, ['Knight of Judgement', 'Captain of Integrity', 'Baron of Justice']);
    end;
    baal:
    begin
      Result := TSuperior.Create('War');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := balseraphs;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(baal)];

      AddServitorAttunement(Result, 'Art of Combat');
      AddServitorAttunement(Result, 'State of Ophis');

      SetDistinctions(Result, ['Knight of the Black Order', 'Captain of the Infernal Armies', 'Baron of Victory']);
    end;
    beleth:
    begin
      Result := TSuperior.Create('Nightmares');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := djinn;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(beleth)];

      AddServitorAttunement(Result, 'Dream Walking');
      AddServitorAttunement(Result, 'Terror');

      SetDistinctions(Result, ['Knight of Restlessness', 'Captain of Headhaunters', 'Baron of Screams']);
    end;
    belial:
    begin
      Result := TSuperior.Create('Fire');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := calabim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(belial)];

      AddServitorAttunement(Result, 'Incendiary');
      AddServitorAttunement(Result, 'Firewalker');

      SetDistinctions(Result, ['Knight of Infernal Furnaces', 'Captain of Ethernal Fire', 'Baron of Demonic Brazier']);
    end;
    haagenti:
    begin
      Result := TSuperior.Create('Gluttony');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := calabim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(haagenti)];

      AddServitorAttunement(Result, 'Consume');
      AddServitorAttunement(Result, 'Devour');

      SetDistinctions(Result, ['Knight of Banquets', 'Captain of Cannibals', 'Baron of Satanic Dishes']);
    end;
    kobal:
    begin
      Result := TSuperior.Create('Dark Humor');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := impudites;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(kobal)];

      AddServitorAttunement(Result, 'Prank');

      SetDistinctions(Result, ['Knight of Derision', 'Captain of Repartee', 'Baron of Hysteria']);
    end;
    kronos:
    begin
      Result := TSuperior.Create('Fate');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := balseraphs;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(kronos)];

      AddServitorAttunement(Result, 'Fated Future');
      AddServitorAttunement(Result, 'Temporal Projection');

      SetDistinctions(Result, ['Knight of the Winged Chariot', 'Captain of the Infernal Hourglass', 'Baron of the Book of Days']);
    end;
    malphas:
    begin
      Result := TSuperior.Create('Factions');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));      
      Result.celestialKind^ := shedim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(malphas)];

      AddServitorAttunement(Result, 'Imbroglio');
      AddServitorAttunement(Result, 'Polarize');

      SetDistinctions(Result, ['Knight of Deception', 'Captain of Broken Promise', 'Baron of Inner Torment']);
    end;
    nybbas:
    begin
      Result := TSuperior.Create('Media');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := impudites;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(nybbas)];

      AddServitorAttunement(Result, 'Soundtrack');
      AddServitorAttunement(Result, 'Subliminal');

      SetDistinctions(Result, ['Knight of Influence', 'Captain of Swank', 'Baron of the Fourth State']);
    end;
    saminga:
    begin
      Result := TSuperior.Create('Death');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := shedim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(saminga)];

      AddServitorAttunement(Result, 'Zombi');
      AddServitorAttunement(Result, 'Vampiric Kiss');

      SetDistinctions(Result, ['Knight of the Dead', 'Captain of the Infernal Legion', 'Baron of the Undead Kingdom']);
    end;
    valefor:
    begin
      Result := TSuperior.Create('Theft');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := calabim;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(valefor)];

      AddServitorAttunement(Result, 'Passage');
      AddServitorAttunement(Result, 'Swipe');

      SetDistinctions(Result, ['Knight of Kleptos', 'Captain of Corsairs', 'Baron of Buccaneers']);
    end;
    vapula:
    begin
      Result := TSuperior.Create('Technology');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      Result.celestialKind^ := habbalah;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(vapula)];

      AddServitorAttunement(Result, 'Invention');

      SetDistinctions(Result, ['Knight of Combustion', 'Captain of Inspector', 'Baron of Gremlins']);
    end;
    lilith:
    begin
      Result := TSuperior.Create('Freedom');
      Result.celestialKind := AllocMem(SizeOf(TCelestialKind));
      SysFreeMem(Result.celestialKind);
      Result.celestialKind := nil;
      Result.name := FAMOUS_SUPERIORS_NAMES[ord(lilith)];
    end;
    else
      Result := nil;
  end;

  // general choir attunements
  if assigned(Result) then
    for i := ord(seraphim) to ord(mercurians) do
    begin
      tempAttunement := TAttunement.Create;
      tempAttunement.superior := Result;
      if IsAngelic(Result) then
        tempAttunement.description := format('%s of %s', [CELESTIAL_KINDS_DESCRIPTORS[i], Result.word])
      else
        tempAttunement.description := format('%s of %s', [CELESTIAL_KINDS_DESCRIPTORS[i + NUMBER_OF_ANGEL_CHOIRS], Result.word]);
      Result.choirAttunements.Add(tempAttunement);
    end;

end;

function IsAngelic(superior: TSuperior): boolean;
begin
  Result := ( (not Assigned(superior.celestialKind)) and (superior.name = 'Yves') ) or
            ( (Assigned(superior.celestialKind)) and (IsAngelic(superior.celestialKind^)) );
end;

end.
